<?php


$home = [
    'namespace' => 'Home',
    'middleware' => ['web', 'access']
];

Route::group($home, function () {
    //微信公众号授权
    Route::any('/wechat', 'WechatController@serve');
    Route::controller('server', 'Server' . CTR);

    //-----------------------客户平台--------------------------------
    Route::get('wxlogin', 'IndexController@getWxLogin');
    Route::any('order/notify', 'OrderController@anyPayNotify'); //线上订单回调
    Route::any('waterbill/notify', 'WaterBillController@anyPayNotify'); //水票回调
    Route::get('shop/index', 'IndexController@getShopList');
    Route::post('member/bind-shop', 'IndexController@postBindShop');
    Route::get('shop/notice', 'IndexController@getNotice');
    Route::get('show/tips', 'IndexController@getTips');
    Route::get('shop/check-status', 'IndexController@getCheckShopStatus');
    Route::get('shop/entrance/{aid}', 'IndexController@getEntrance');
    Route::post('simple', 'IndexController@postSimple');
    Route::get('sms', 'IndexController@getSmsCaptcha');

    Route::get('member/refer', 'IndexController@getCommissionQr');
    //生成验证码
    Route::get('client/captcha', function () {
        $config = [
            'useCurve' => false,
            'useNoise' => false,
            'fontSize' => 30,
        ];
        return generate_captcha($config);
    });

    Route::group(['middleware' => 'checkWxLogin'], function () {
        Route::get('shop/info', 'IndexController@getShopInfo');
        Route::get('goods/index', 'IndexController@getGoodsList');
        Route::get('waterbill/index', 'IndexController@getWaterBillList');
        Route::get('waterbill/info', 'IndexController@getWaterBillInfo');
        Route::get('member-waterbill/index', 'IndexController@getMemberWaterBillList');
        Route::get('goods-category/index', 'IndexController@getGoodsCategory');
        Route::get('pay/method', 'IndexController@getPayMethod');
        Route::post('notify/check', 'IndexController@postCheckOrderStatus');

        //收货地址
        Route::controller('address', 'Address' . CTR);

        Route::controller('member', 'Member' . CTR);

        Route::post('waterbill/add', 'WaterBillController@postAdd'); //水票支付
        Route::post('waterbill/pay', 'WaterBillController@postPay'); //水票支付
        Route::get('waterbill/check-status', 'WaterBillController@getCheckStatus'); //检查订单支付状态

        Route::get('order/index', 'OrderController@getIndex'); //订单列表
        Route::post('order/add', 'OrderController@postAdd'); //线下订单处理
        Route::post('order/add-bill-order', 'OrderController@postAddBillOrder'); //水票订单处理
        Route::get('order/detail', 'OrderController@getDetail'); //订单详情
        Route::get('order/check-status', 'OrderController@getCheckStatus'); //检查订单支付状态
        Route::get('order/delete', 'OrderController@getDelete'); //删除订单
        Route::post('order/pay', 'OrderController@postPay'); //线上订单处理

        Route::get('share/qr-link', 'MemberController@getQrLink'); // 生成QR链接
        Route::get('invite', 'IndexController@getInviteMember'); // 邀请注册

        Route::get('goods/bill', 'IndexController@getGoodsListWithBill');//专属码下单页商品列表

//        Route::get('authopenid', function () {
//            tolog(['openid'=>request('openid')]);
//            $saoPay = new \App\Models\SaoPay();
//            $sid = 80;
//            $saoPay->getOpenId($sid);
//        });
    });
    //-----------------------商户平台--------------------------------
    Route::post('worker/login', 'WorkerController@postLogin');  //送水工登录
    Route::group(['middleware' => 'checkWorkerLogin'], function () {
        Route::get('worker/info', 'WorkerController@getInfo');     //送水工个人中心
        Route::post('worker/pwd', 'WorkerController@postModifyPwd'); //送水工修改密码
        Route::get('worker/search', 'WorkerController@getSearch'); //客户搜索
        Route::get('worker/select-data', 'WorkerController@getSelectData'); //导客下拉列表数据
        Route::get('worker/order-info', 'WorkerController@getOrderInfo'); //待接单列表
        Route::get('worker/order-list', 'WorkerController@getIndex'); //待接单列表
        Route::get('worker/order-send-list', 'WorkerController@getOrderList'); //已接单订单列表
        Route::get('worker/order-send', 'WorkerController@getSend'); //订单派送
        Route::get('worker/order-resend', 'WorkerController@getReSend'); //订单改派
        Route::post('worker/import', 'WorkerController@postImport'); //老客户导入
        Route::post('worker/complete', 'WorkerController@postComplete'); //回桶操作
        Route::post('worker/recover-bucket', 'WorkerController@postRecoverBucket'); //回桶操作
        Route::get('worker/remove-bindwx', 'WorkerController@getRemoveBindWx'); //绑定微信
        Route::get('worker/bindwx', 'WorkerController@getBindWx'); //绑定微信
        Route::post('worker/bindwx', 'WorkerController@postBindWx'); //绑定微信
        Route::get('worker/wx-info', 'WorkerController@getWxInfo'); //绑定微信
        Route::get('worker/bill-charge', 'WorkerController@getBillCharge'); //绑定微信
        Route::post('worker/bill-charge', 'WorkerController@postBillCharge'); //绑定微信
        Route::get('worker/create-order', 'WorkerController@getCreateOrder'); //自助下单
        Route::post('worker/create-order', 'WorkerController@postCreateOrder'); //自助下单
        Route::post('worker/wx-config', 'WorkerController@postWxConfig'); //获取jssdk
    });

    // -----  共享水票  -----
    Route::group(['middleware' => 'checkQrKey'], function () {
        Route::get('share/bill-info', 'MemberController@getBillInfo'); // 用户水票列表
        Route::get('share/address-list', 'MemberController@getAddressList'); // 用户收货地址
        Route::post('share/bill-add', 'MemberController@postBillAdd'); // 提交共享水票下单数据
    });
});